// 1.引入核心文件
import { createRouter,createWebHashHistory } from "vue-router";
// 引入组件
import Login from "@/views/login/index.vue";
import Layout from "@/views/layout/index.vue";
import { MyRouterRecordRaw } from "@/typing/router";

// 2.配置路由一一对应的关系
let routes:Array<MyRouterRecordRaw> = [
    {
        path: "/",
        redirect: "/login",
        isshow: true
    },
    {
        path: "/login",
        component: Login,
    },
    // 后台首页
    {
        path: "/home",
        component: Layout,
        redirect: "/home/index",
        meta: {
            title: "后台首页"
        },
        children: [
            {
                path: "index",
                meta: {
                    title: "数据中心"
                },
                component: ()=>import("@/views/home/index.vue")
            }
        ]
    },
    // 客服中心
    {
        path: "/server",
        component: Layout,
        redirect: "/server/order",
        meta: {
            title: "客服中心"
        },
        children: [
            {
                path: "order",
                meta: {
                    title: "订单管理"
                },
                component: ()=>import("@/views/server/order.vue")
            }
        ]
    },
    // 审核
    {
        path: "/examine",
        component: Layout,
        redirect: "/examine/shop",
        meta: {
            title: "审核中心"
        },
        children: [
            {
                path: "shop",
                meta: {
                    title: "店铺审核"
                },
                component: ()=>import("@/views/examine/shop.vue")
            },
            {
                path: "master",
                meta: {
                    title: "师傅审核"
                },
                component: ()=>import("@/views/examine/master.vue")
            }
        ]
    },
    // 运营
    {
        path: "/operate",
        component: Layout,
        redirect: "/operate/special",
        meta: {
            title: "运营中心"
        },
        children: [
            {
                path: "special",
                meta: {
                    title: "专题管理"
                },
                component: ()=>import("@/views/operate/special.vue")
            },
            {
                path: "project",
                meta: {
                    title: "项目管理"
                },
                component: ()=>import("@/views/operate/project.vue")
            }
        ]
    },
    // 管理中心
    {
        path: "/manage",
        component: Layout,
        redirect: "/manage/company",
        meta: {
            title: "管理中心"
        },
        children: [
            {
                path: "company",
                meta: {
                    title: "公司管理"
                },
                component: ()=>import("@/views/manage/company.vue")
            },
            {
                path: "department",
                meta: {
                    title: "部门管理"
                },
                component: ()=>import("@/views/manage/department.vue")
            }
        ]
    },
    // 账号中心
    {
        path: "/acc",
        component: Layout,
        redirect: "/acc/acclist",
        meta: {
            title: "账号中心"
        },
        children: [
            {
                path: "acclist",
                meta: {
                    title: "账号列表"
                },
                component: ()=>import("@/views/acc/acclist.vue")
            },
            {
                path: "accadd",
                meta: {
                    title: "账号添加"
                },
                component: ()=>import("@/views/acc/accadd.vue")
            },
            {
                path: "accedit",
                meta: {
                    title: "密码修改"
                },
                component: ()=>import("@/views/acc/accedit.vue")
            },
            {
                path: "personel",
                meta: {
                    title: "个人中心"
                },
                component: ()=>import("@/views/acc/personel.vue")
            }
        ]
    },
    // 404
    {
        path: "/404",
        component: () => import("@/views/err/index.vue")
    },
    // 容错页的配置
    {
        path: "/:pathMatch(.*)*",
        component: () => import("@/views/err/index.vue")
    }
]
// 3.创建路由实例
let router = createRouter({
    routes,
    history: createWebHashHistory()
})
// 4.暴露路由对象
export default router